package cn.signalpha.modules.shop.controller.api;

import cn.signalpha.common.constant.AppConstant;
import cn.signalpha.core.boot.ctrl.BaseController;
import cn.signalpha.core.redis.cache.RedisCache;
import cn.signalpha.core.tool.api.R;
import cn.signalpha.modules.shop.entity.Adorn;
import cn.signalpha.modules.shop.service.AdornService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 控制器
 *
 * @author signalpha
 */
@RestController
@AllArgsConstructor
@RequestMapping(AppConstant.APPLICATION_SHOP_NAME + "/wap/adorn")
@Api(value = "页面装修", tags = "页面装修")
public class ApiAdornController extends BaseController {

	private final RedisCache redisCache;
	private final AdornService adornService;

	@GetMapping("/info")
	@ApiOperation(value = "详情", notes = "")
	public R<Adorn> info() {
		return R.data(adornService.getByUse());
	}

	@GetMapping("/detail")
	@ApiOperation(value = "详情", notes = "传入id")
	public R<Adorn> info(@ApiParam(value = "主键", required = true) @RequestParam Long id) {
		return R.data(adornService.getById(id));
	}

	@GetMapping("/get/data")
	@ApiOperationSupport(order = 5)
	@ApiOperation(value = "获取预览页面参数", notes = "")
	public R wechatShareCodeGetKey(@RequestParam String key) {
		return R.data(redisCache.get(key));
	}

}
